package inventory.view;

import java.awt.Color;

import javax.swing.AbstractListModel;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.SpringLayout;
import javax.swing.border.LineBorder;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.JButton;

public class Outward extends JPanel {
	private JList list1;
	private JTable table;
	private JButton btnApprove;

	Outward()
	{
		SpringLayout sl_this = new SpringLayout();
		this.setLayout(sl_this);
		
		
		JScrollPane scrollPane_2 = new JScrollPane();
		sl_this.putConstraint(SpringLayout.NORTH, scrollPane_2, 10, SpringLayout.NORTH, this);
		sl_this.putConstraint(SpringLayout.WEST, scrollPane_2, 121, SpringLayout.WEST, this);
		sl_this.putConstraint(SpringLayout.SOUTH, scrollPane_2, -36, SpringLayout.SOUTH, this);
		sl_this.putConstraint(SpringLayout.EAST, scrollPane_2, -10, SpringLayout.EAST, this);
		this.add(scrollPane_2);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"SR NO.", "ITEMS", "SPECIFICATION", "UNIT", "REQ QTY", "ISSUE QTY"
			}
		) {
			boolean[] columnEditables = new boolean[] {
				false, false, false, false, true, true
			};
			public boolean isCellEditable(int row, int column) {
				return columnEditables[column];
			}
		});
		table.getColumnModel().getColumn(1).setPreferredWidth(136);
		table.getColumnModel().getColumn(2).setPreferredWidth(113);
		scrollPane_2.setViewportView(table);
		
		JLabel lblOpenIssueSlips = new JLabel("OPEN ISSUE SLIPS");
		sl_this.putConstraint(SpringLayout.NORTH, lblOpenIssueSlips, 10, SpringLayout.NORTH, this);
		this.add(lblOpenIssueSlips);
		
		list1 = new JList();
		sl_this.putConstraint(SpringLayout.NORTH, list1, 2, SpringLayout.SOUTH, lblOpenIssueSlips);
		sl_this.putConstraint(SpringLayout.SOUTH, list1, -33, SpringLayout.SOUTH, this);
		list1.setBorder(new LineBorder(new Color(0, 0, 0)));
		sl_this.putConstraint(SpringLayout.WEST, list1, 10, SpringLayout.WEST, this);
		sl_this.putConstraint(SpringLayout.EAST, list1, 100, SpringLayout.WEST, this);
		list1.setModel(new AbstractListModel() {
			String[] values = new String[] {};
			public int getSize() {
				return values.length;
			}
			public Object getElementAt(int index) {
				return values[index];
			}
		});
		this.add(list1);
		list1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 
		
		btnApprove = new JButton("APPROVE");
		sl_this.putConstraint(SpringLayout.NORTH, btnApprove, 6, SpringLayout.SOUTH, scrollPane_2);
		sl_this.putConstraint(SpringLayout.EAST, btnApprove, -242, SpringLayout.EAST, this);
		add(btnApprove);

	}

	public JList getList1() {
		return list1;
	}

	public void setList1(JList list1) {
		this.list1 = list1;
	}
	
	
	
	public JTable getTable() {
		return table;
	}

	public void setTable(JTable table) {
		this.table = table;
	}

	public JButton getBtnApprove() {
		return btnApprove;
	}

	public void setBtnApprove(JButton btnApprove) {
		this.btnApprove = btnApprove;
	}

	public void addlistlistener(ListSelectionListener ls)
	{
		list1.addListSelectionListener(ls);
	}

}
